# coding: utf-8
import os.path

basedir = os.path.abspath(os.path.dirname(__file__))


class Config:
    SECRET_KEY = 'yxg995995'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    MAIL_SERVER = 'smtp.qq.com'
    MAIL_USE_TLS = True
    MAIL_PORT = 587
    MAIL_USERNAME = '2931148038@qq.com'
    MAIL_PASSWORD = 'wzgmyqwcxubsdffd'
    MAIL_DEFAULT_SENDER = ('YXG', '2931148038@qq.com')
    BLOG_POST_PER_PAGE = 10
    CKEDITOR_SERVE_LOCAL = True
    AVATARS_SAVE_PATH = os.path.join('static', 'avatars')
    AVATARS_SIZE_TUPLE = (30, 90, 120)
    MAX_CONTENT_LENGTH = 3*1024*1024
    UPLOAD_PATH = 'app/static/avatars'
    WHOOSHEE_MIN_STRING_LEN = 1
    YEAR = 2021

    # celery配置
    CELERY_BROKER_URL = "redis://:yxg579521..@101.37.32.9:63791/8"
    RESULT_BACKEND = "redis://:yxg579521..@101.37.32.9:63791/8"
    REDIS_URL = 'redis://:yxg579521..@101.37.32.9:63791/0'
    REDIS_CACHE_URL = 'redis://:yxg579521..@101.37.32.9:63791/2'
    REDIS_GAME_URL = 'redis://:yxg579521..@101.37.32.9:63791/3'

    SQLALCHEMY_BINDS = {
        "master": 'postgresql://yxg:yxg579521..@101.37.32.9/test',
        "slave1": 'postgresql://yxg:yxg579521..@43.142.192.44/test'
    }

    @staticmethod
    def init_app(app):
        pass


class DevelopmentConfig(Config):
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = 'postgresql://yxg:yxg579521..@101.37.32.9/test'
    # SQLALCHEMY_DATABASE_URI = 'postgresql://yxg123:123456@106.12.119.119/blog'
    REDIS_URL_CACHE = 'redis://:yxg579521..@101.37.32.9:63791/2'
    REDIS_URL_GAME = 'redis://:yxg579521..@101.37.32.9:63791/3'


class ProductConfig(Config):
    DEBUG = False
    SQLALCHEMY_DATABASE_URI = 'postgresql://yxg:yxg579521..@101.37.32.9/test'
    REDIS_URL_CACHE = 'redis://:yxg579521..@101.37.32.9:63791/1'
    REDIS_URL_GAME = 'redis://:yxg579521..@101.37.32.9:63791/3'


config = {
    'development': DevelopmentConfig,
    'default': DevelopmentConfig,
    'product': ProductConfig
}
